{% extends site.theme|stringformat:"s/include/simplebase.html" %}{% block script %}
{% endblock %}{% block mainer %}
<form id="fmUpload" method="post" action="/uploadImage/{{path.dir}}/{{path.path}}.do" encType="multipart/form-data" target="hiddenFrame">
<div class="uploadimg" style="padding: 10px;"> 
	<input id="image" type="file" name="image" style="padding: 5px 0px;"><br />
	<input type="button" id="btnUpload" value="上传图片">
	<span id="msg" style="display: none; background-color: #FF0000; color:#FFFFFF; margin:2px 6px; padding: 3px 6px;" ></span><br />
	<div style="height:180px;"><center><img class="bgimgPre" id="imgPre" /></center></div>
	<iframe name='hiddenFrame' id="hiddenFrame" style="display:none;"></iframe>
</div>
</form>
<script type="text/javascript">
<!-- 
fileBind();
function fileBind(){
	$('#image').bind('change', function(){
		$("#imgPre").attr("src", "file:////"+$('#image').val());
	});
	$('#btnUpload').bind('click', function(){
		fileUpload();
	});
}
function fileUpload(){
	if($('#image').val()==''){
		setMsg('请先选择图片！');
		return;
	}
	setMsg('处理中......');
	$('#fmUpload').submit();
	$("#imgPre").attr("src", "");
	$("#imgPre").attr("css", "bgimgPre");
}
function callback(){
	hfc = $("#hiddenFrame").contents();
	setMsg(hfc.find("#msg").html());
	if(hfc.find('#flag').html()=='True'){
		$("#imgPre").attr("css", "okimgPre");
		$("#imgPre").attr("src", "/media/{{path.dir}}/"+hfc.find("#url").html());
	}
}
function setMsg(msg){
	if(msg!=''){
		$('#msg').css("display","");
		$('#msg').html(msg);
	}else{
		$('#msg').css("display","none");
	}
}
//-->
</script>
{% endblock %}